package com.five.welcome.controller;


import com.five.welcome.entity.Goodsget;
import com.five.welcome.result.Result;
import com.five.welcome.service.GoodsgetService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ywt
 * @since 2024-07-12
 */
@RestController
@CrossOrigin
@Tag(name = "物资领取接口")
@RequestMapping("/goodsget")
public class GoodsgetController {

    @Autowired
    private GoodsgetService goodsgetService;

    //添加领取信息
    @Operation(summary = "添加领取信息")
    @PostMapping("/addGoodsGet")
    public Result addGoodsGet(String sNumber){
        goodsgetService.addGoodsGet(sNumber);
        return Result.ok();
    }

    //查询学生是否领取
    @Operation(summary = "查询学生是否领取")
    @GetMapping("/IsGet")
    public Result IsGet(String sNumber){
        List<Goodsget> goodsgets=goodsgetService.IsGet(sNumber);
        if(!goodsgets.isEmpty()){
            return Result.error("您已经领取过了");
        }
        return Result.ok();
    }
}

